<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>组件的能够使用 Vue 对象数据</title>
</head>
<body>
<div id="app">
    <cpn></cpn>
</div>

<!--使用 template 标签定义组件的模板-->
<template id="cpn">
    <h1>这个自定义组件标题</h1>
    <div>这是自定义组件内容</div>
    <div>{{ info }}</div>
</template>

<script type="module">
    import {createApp, defineComponent, ref} from "../../../js/vue.esm-browser.js";

    let cpn = defineComponent(
        {
            template: "#cpn"
        }
    )

    let app = createApp(
        {
            setup() {
                let info = ref("Hello, Vue!")
                return {
                    info,
                }
            }
        }
    );

    app.component("cpn", cpn)

    app.mount("#app")
</script>
</body>
</html>